package utils;

import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.collections.ObservableMap;

import java.util.LinkedHashMap;

/**
 * Created by nuno-rafael-figueiredo on 01-07-2014.
 */
public class MyList<T extends Base> {
    private final ObservableMap<String, T> map = FXCollections.observableMap(new LinkedHashMap<>());
    private final ObservableList<T> list = FXCollections.observableArrayList();

    public ObservableMap<String, T> getMap() {
        return map;
    }

    public ObservableList<T> getList() {
        return list;
    }

    public void add(T item) {
        map.put(item.getName(), item);
        list.add(item);
    }

    public T get(String name) {
        return map.get(name);
    }
}
